package com.aistar.order.controller;

import com.aistar.common.vo.Result;
import com.aistar.common.vo.StatusCode;
import com.aistar.order.entity.HotelOrder;
import com.aistar.order.entity.OrderBill;
import com.aistar.order.service.IOrderBillService;
import com.aistar.order.util.MailUtils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.Date;
import java.util.Random;

/**
 * Created by Administrator on 2019/7/2 0002.
 */
@Controller
public class EmailController {

    @Autowired
   private MailUtils mailUtils;

    @Autowired
   private IOrderBillService service;

    //发送验证码
    @GetMapping("/email/{email}")
    public Result message(@PathVariable("email") String email){

//         后期更具订单状态判断是否要 发送订单

//         String title =  hotelOrder.getOrderId() ;
//         String text = "订单号:"+hotelOrder.getId()+"   订单价格:"+hotelOrder.getOrderPrice();
//                text += "入住时间:"+hotelOrder.getInDate()+"   离店时间:"+hotelOrder.getOutDate();
//        通过订单关联发票
//        String bill = hotelOrder.getBillId();
//        OrderBill o = service.findById(bill);
//        text += "签收类型:" + o.getType() +"   签收人:"+ o.getInfo();

//        发太多变成垃圾箱
                 Date d = new Date();
       double random = Math.random();
        System.out.println(email);
       mailUtils.sendMail(email,"text"+d,"title"+random);
       Result result=new Result(true, StatusCode.OK,"已发送",email);
        System.out.println(result.getMessage());
        return result;
    }

}
